-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid using 2nd argument of Array.from that prototype.js does not support #1464
Conversation
🦋 Changeset detectedLatest commit: 7f96331 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
8e23d80
to
50d400e
Compare
Prior to me examining this further:
|
Having had a quick look, we'll need something better than reverting #1272 which is kind of what this is ...
Notwithstanding #1196, I think that's more suitable for code outside of rrweb, as prototype.js is old and doesn't do this anymore right? |
@eoghanmurray that is all very fair hence why I said we weren't sure if opening this PR is really worth it and wanted to get your opinion. Ultimately we at Pendo run rrweb in such a wide array of applications that are outside of our control and often are using old frameworks, weird polyfills, weird prototype changes, etc. and so have to find ways to keep rrweb stable in such hostile environments. This is one such change that we had made that worked for us and I would love to find an easy to not keep such a silly change in our fork but just stick to upstream so ultimately opening the PR was to see if this sort of change or one similar that addresses the same issue makes sense to get upstream in any way. Ultimately it is likely that another
This doesn't really equate to reverting #1272 at all however, since that was making it so that we only loop over the list once instead of once to create it into an array and then once to map it to a stringified value. This change still results in a single loop it just does it using a standard loop instead of Array.from's map parameter.
This is the bigger question. Prototype.js does still do this and anyone that uses prototype.js will be getting errors when they try to use rrweb. Yes prototype.js is old and not used very widely but it is still used sadly so it comes down to what is the best way to support people that use libraries like this I guess. We at Pendo will do what we have to do to support these types of applications and altering rrweb was the solution we came up with but maybe there is some better middle ground that doesn't require forcing rrweb to support |
Also "there isn't really a good reason or a sustainable way to do this in rrweb" is a totally reasonable final decision. This was a combination of me going through our current changes that have diverted from upstream and making sure I at least saw if there was a good way to do it. |
Apologies I missed that the changes do not add a new array. I knew I'd seen this problem before; here's what we do at Statcounter (before rrweb is run):
This could conceivably be added to packages/rrweb/src/record/index.js - take a stab at it if you like! |
f36ecc9
to
6573c9b
Compare
@eoghanmurray good idea. I have done that with other tools before just for some reason didn't think about trying that here. Probably was trying to be as surgical as possible which might have made sense for a quick hotfix on our part but definitely doesn't make as much sense for the long term evolution of rrweb. |
6540a89
to
938d277
Compare
Thanks for working out the typing issues! I'll leave it to another to review as I won't have seen problems in the code I suggested. |
This work is to try to provide support where rrweb might be included in applications with various tools that might override Array.from so that the 2nd parameter (the map function) will always work for rrweb.
938d277
to
7f96331
Compare
Fwiw, I've debugged the exact same issue this week where a site had overridden the |
This work is to try to provide support where rrweb might be included in applications with various tools that might override Array.from so that the 2nd parameter (the map function) will always work for rrweb. Co-authored-by: Michael Dellanoce <[email protected]>
This work is to try to provide support where rrweb might be included in applications with various tools that might override Array.from so that the 2nd parameter (the map function) will always work for rrweb. Co-authored-by: Michael Dellanoce <[email protected]>
This work is to try to provide support where rrweb might be included in applications with various tools that might override Array.from so that the 2nd parameter (the map function) will always work for rrweb. Co-authored-by: Michael Dellanoce <[email protected]>
This work is to try to provide support where rrweb might be included in applications with various tools that might override Array.from so that the 2nd parameter (the map function) will always work for rrweb. Co-authored-by: Michael Dellanoce <[email protected]>
We ran into an issue where rrweb running on a site that uses prototype.js breaks prototype overrides native Array.from to not support the 2nd argument (the mapFn). We struggled with if it was right to open this pr against upstream due to it only being necessary to support a mostly abandoned tool but thought we would open it anyways and get your opinions on it.